<%var jstpl = {%>
<script>
var  app =  new Vue({
	el:"#gexin_body",
	data:{
		query:{nickname:"",sex:"",appConfigId:"",pageNumber:1,pageSize:10},
		data_result:{}
	},created:function(){
		this.loadPage("init")
	},methods:{
		loadPage:function(model){  //载入模式有两种  init初始化载入 load分页载入
			if(model=="init"){
				this.query.pageNumber=1;
			}
			Ajax("/system/weixin/userlist/query",this.query,function(d){
				app.data_result=d;
			    if(d.firstPage==true){
				  layui.laypage.render({
					elem: 'gexin_page' //注意，这里的 test1 是 ID，不用加 # 号
					,layout:['count', 'prev', 'page', 'next', 'limit', 'skip']
					,count: d.totalRow //数据总数，从服务端得到
					,limit:app.query.pageSize
					,jump: function(obj, first){
						app.query.pageNumber=obj.curr;
						if(app.query.pageSize!=obj.limit){
						 app.query.pageSize=obj.limit;
						 app.loadPage("init");
						 return ;
						}
					    if(!first){
						   app.loadPage("load");
						}
					 }
				  });
				}
			})
		},sync:function(){
			var id=$("#appConfigId").val();
			if(id==""){
				gx.alert("请选择公众号!");
			}else{
			Ajax("/system/weixin/userlist/sync_user?id="+id,function(d){
				if(d.state==true){
					gx.alert("同步成功!");
					app.loadPage("load");
				}			
			})
		  }
		}
	}
})

function appConfigId_change(){
	app.query.appConfigId=$("#appConfigId").val();
	app.loadPage("init");
}

function sex_change(){
	app.query.sex=$("#sex").val();
	app.loadPage("init");
}

</script>
<%};%>
<%var csstpl = {%>
   <style type="text/css">
   [v-cloak]{display:none}
   </style>
<%};%>
<%layout("../layout/_layout_layui.html",{title:'日志管理',jstpl:jstpl,csstpl:csstpl}){ %>
<div class="layui-row"  v-cloak>
<div class="layui-col-md12">
  <div class="layui-col-md3">
         <div class="layui-form-item ">
         <label class="layui-form-label" >微信昵称</label>
	    <div class="layui-input-block">
	      <input type="text" name="nickname" v-model="query.nickname"  placeholder="请输入微信昵称" autocomplete="off" class="layui-input">
	    </div>	
     </div>
  </div>
  
    <div class="layui-col-md3">
         <div class="layui-form-item">
		    <label class="layui-form-label">性别</label>
		    <div class="layui-input-block">
		    <#select   attr='name="sex "  id="sex" onchange="sex_change()" class="layui-input" v-model="query.sex" ' listdata="${@AppConst.sexmap}" value="${sex!}"  headkey="" headtext="所有类型"/>
		    </div>
		  </div>
  </div>

    <div class="layui-col-md3">
         <div class="layui-form-item">
		    <label class="layui-form-label">公众号</label>
		    <div class="layui-input-block">
			<select class="layui-input" name="appConfigId" id="appConfigId" v-model="query.appConfigId" onchange="appConfigId_change()">
			<option selected="selected" value="">请选择</option>
			<%for(a in wxAppConfigs){%>
			<option value="${a.id!}">${a.app_title!}</option>
			<%}%>
			</select>
		    </div>
		  </div>
  </div>	
  
  <div class="layui-col-md3">
   <div class="layui-form-item">
  <div class="layui-inline">
    <div class="layui-input-block" >
       <button type="button" @click="loadPage('init')" class="layui-btn layui-btn-normal">查询</button>
       <button type="button" @click="sync()" class="layui-btn layui-btn-warm">微信同步粉丝</button>
    </div>
  </div>
   </div>
  </div>
  
</div>

<div class="layui-col-md12" style="margin-top: 20px">
 <table class="layui-table">
        <thead>
            <tr>
                <th>ID</th>
                <th>头像</th>
                <th>昵称</th>
                <th>性别</th>
                <th>区域</th>
                <th>是否关注</th>
                <th>关注时间</th>
          	</tr>
        </thead>
      <tbody id="tbody_body">
        <tr v-for="d  in  data_result.list">
        <td>{{d.id}}</td>
        <td v-if="d.headimgurl==null"><img src="http://58pic.ooopic.com/58pic/15/83/09/58PIC9J58PICc2U.jpg" class="layui-nav-img"></td>
        <td v-else><img :src="d.headimgurl" class="layui-nav-img"></td>
        <td>{{d.nickname}}</td>
		<td v-if="d.sex=='0'" >未知</td>
		<td v-else-if="d.sex=='1'" >男</td>
		<td v-else-if="d.sex=='2'" >女</td>
		<td v-else></td>
		<td>{{d.country}}&nbsp{{d.province}}&nbsp{{d.city}}</td>
		<td><span v-if="d.subscribe=='0'" class="layui-badge layui-bg-orange">未关注</span>
		<span v-if="d.subscribe=='1'" class="layui-badge layui-bg-blue">已关注</span>
		<span v-if="d.subscribe==null" class="layui-badge layui-bg-red">未知</span></td>
		<td>{{d.subscribe_time}}</td>
        </tr>
		<tr v-if="data_result.list==0">
		 <td  colspan="7" style="text-align:center;height:300px"><h1>没有数据</h1></td>
		</tr>
      </tbody >
    </table>
<fieldset id="gexin_page" class="layui-elem-field layui-field-title" >
</fieldset>
</div>
</div>
<%};%>